/**
 * 
 */
package com.wgo.bpot.client.session;

import static com.wgo.bpot.client.session.LightSession.DEFAULT_UPDATE_DEPTH;
import static com.wgo.bpot.common.transport.util.MethodNamingConvention.PROXY_SUPER_INTERFACE;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;

import com.wgo.bpot.common.transport.servicefacade.DispatchedModifyingMethodsTransport;
import com.wgo.bpot.common.transport.util.Assert;
import com.wgo.bpot.common.transport.util.MethodNamingConvention;



/**
 * @author petterei
 * @version $Id: DomainProxy.java,v 1.4 2006-01-24 12:11:23 petterei Exp $
 */
public interface DomainProxy<T> {

	/**
	 * Time before new update from server is triggered (if possible).
	 */
	public static final long CACHE_TIMEOUT = 1000 * 60 * 30; // 30 minutes

	/**
	 * Indicates if modifying methods is dispatched.
	 * 
	 * @return boolean if dirty or not.
	 */
	public boolean isDirty();
	
	/**
	 * @return The actual concept the proxy handles invokations for.
	 */
	public T getActualDomainModelObject();
	
	/**
	 * Returns all dispatched methods dispatched on the concept since last 
	 * retrieved from persistent store or created. Used for saving changes to 
	 * persistent store with fine granularity. Opposite methods, such as 
	 * 'add(instance)' and 'remove(instance)' are ignored. The methods linked 
	 * concepts to collect their dispatched methods.
	 *  
	 * @param dispatchedModifyingMethods The collection of dispatched methods 
	 * for all dirty concepts.
	 * @param proxy The initial proxy.
	 * /@/param traversalVisitedMark Used for efficient and accurate traversal of 
	 * the linked concepts.
	 */
	public void getDispatchedModifyingMethods(Map<DispatchedModifyingMethodsTransport, DomainProxy> dispatchedModifyingMethods, DomainProxy<T> proxy, Set<DomainProxy> backTrace);
	public T updateFromPersistentStore(T savedConcept, DomainProxy<T> proxy, Long serverTime);
	public void cleanUpAfterSave(DomainProxy proxy);
	public Long getTimeOfRetrieval();
	void update(T completeConcept, int updateDepth, T backTrace, DomainProxy proxy);
	void putDirtyMethod(Method method, Object arg, Object result);
}

